home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
- *
- *
- * MacZoop - "the framework for the rest of us"
- *
- *
- *
- * ZFile.h -- a generic file object
- *
- *
- *
- *
- *
- * © 1996, Graham Cox
- *
- *
- *
- *
- *************************************************************************************************/
-
-
-
- #pragma once
-
- #ifndef __ZFILE__
- #define __ZFILE__
-
- #ifndef __ZCOMRADE__
- #include "ZComrade.h"
- #endif
-
- #include <Files.h>
-
- class ZGWorld;
-
- enum
- {
- CLASS_ZFile = 'zfil'
- };
-
-
- class ZFile : public ZComrade
- {
- protected:
-
- short refNum; // data fork ref num when open
- short resRefNum; // resource fork ref num when open
- Boolean isSafeSave; // TRUE if this was a safe-save Write
- OSType itsType; // file type
- OSType itsCreator; // file creator- initialised to application creator type
- FSSpec itsSpec; // file spec (name and location)
- FSSpec ssFSpec; // temp file spec for safe-save
- long tempFID; // temp folder ID
- short tempFVolID; // temp folder volume
-
- public:
-
- ZFile( const FSSpec& aSpec );
- ZFile( Str255 fName );
- ZFile();
- ~ZFile();
-
- // file opening and closing
- virtual void Open();
- virtual void Close();
- virtual void OpenSafe();
-
- // creating/destroying a new file on disk
- virtual void Create();
- virtual void Discard();
-
- // accessing the resource fork
- virtual void OpenResFork();
- virtual void CloseResFork();
- virtual void CreateResFork();
- virtual void SetResFork( short* curRes );
-
- // reading and writing file data
- virtual void Read( Ptr inBuffer, long* howMuch );
- virtual void Write( Ptr outBuffer, long* howMuch );
- virtual void Read( Handle aHandle );
- virtual void Write( Handle aHandle );
-
- // file positioning and info
- virtual long GetMark();
- virtual void SetMark( const long aMark );
-
- virtual OSType GetType();
- virtual void SetType( const OSType aType );
- virtual void SetCreator( const OSType aCreator );
-
- virtual long GetLength();
- virtual void SetLength( const long aLength );
-
- virtual void GetFSSpec( FSSpec* aSpec );
- virtual void GetInfo( FInfo* fi );
- virtual void SetInfo( FInfo* fi );
-
- // fork info
- virtual Boolean HasResFork();
- virtual Boolean HasDataFork();
-
- // disk file info
- virtual Boolean IsReal();
- virtual Boolean IsLocked();
- virtual Boolean IsOpen();
-
- inline short GetRefNumber() { return refNum; };
- inline short GetResourceRefNumber() { return resRefNum; };
-
- // making custom icons for the file:
-
- virtual void MakeCustomIcon( PicHandle srcImage );
- virtual void MakeCustomIcon( ZGWorld* srcImage );
- protected:
-
- virtual void InitFile();
- virtual Handle ConstructCustomIconSuite( PicHandle srcPic );
- virtual void SaveCustomIconSuite( Handle icnSuite );
-
- void GetTempFolderID();
- };
-
-
- #define _NOT_OPEN -1
- #define kUnknownType '????'
-
- #endif